﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PolePosition.v3.Desktop.Selectors.Controls
{
    public partial class Polygons : DialogEditBase
    {
        public Polygons()
        {
            InitializeComponent();
        }

        private void Polygons_Load(object sender, EventArgs e)
        {
            BindLists();
        }
        
        public string SelectedMapList
        {
            get { return listSelectorMaps.GetSelectedValueList<int>(); }
            set { listSelectorMaps.SetSelectedValueList<int>(value); }
        }

        private void BindLists()
        {
            if (Program.LoginResult != null)
            {
                listSelectorMaps.DisplayMember = EntityLibrary.UtilityPolygonEnumerations.Columns.Name.ToString();
                listSelectorMaps.ValueMember = EntityLibrary.UtilityPolygonEnumerations.Columns.Utility_PolygonId.ToString();
                listSelectorMaps.DataSource = Program.LoginResult.Polygons;
                listSelectorMaps.AddBlankOption<EntityLibrary.UtilityPolygonEntity>();

                SetListsEnabled();
            }
        }

        private void checkBoxXViewAll_CheckedChanged(object sender, EventArgs e)
        {
            SetListsEnabled();
        }

        private void SetListsEnabled()
        {
            bool _Enabled = !checkBoxXViewAll.Checked;

            foreach (Control _List in panelSelectors.Controls)
            {
                (_List as ListSelector).Enabled = _Enabled;
            }
        }
    }
}
